﻿using System.ComponentModel.Composition;
using Caliburn.Micro;
using DomusDotNet.Sbm.Client.SL4.WCFServices;
using System;
using System.Windows;

namespace DomusDotNet.Sbm.Client.SL4.ViewModels
{
    [Export]
    [PartCreationPolicy(CreationPolicy.NonShared)]
    public class BookViewModel : Screen
    {
		IShell shell;
		[ImportingConstructor]
		public BookViewModel(IShell shell){
			this.shell  = shell;
			this.DisplayName = "Dettaglio";
		}


        public BookBase Book { get; set; }


		public void Back() {
			shell.Back();
		}

		public bool SupportsBack {
			get { return Parent != null; }
		}

		public override void CanClose(Action<bool> callback)
		{
			var canClose = MessageBox.Show("Sei proprio sicuro?","SBM", MessageBoxButton.OKCancel) == MessageBoxResult.OK;
			callback(canClose);
		}

		public class Factory
		{
			[Export(typeof(Func<BookViewModel>))]
			public static BookViewModel Create() { return IoC.Get<BookViewModel>(); }
		}
    }
}
